import {queryMyTableDatas, addMyTableDatas} from '../services/api';

export default {
  namespace: 'mytable',

  state: {
    data: [],
    loading: true,
  },
  effects: {
    *fetchMyData(_, { call, put }) {
      const response = yield call(queryMyTableDatas);
      console.log(response)
      yield put({
        type: 'showTableData',
        payload: response,
      });
    },
    *addMember(_, { call, put }) {
      const response = yield call(addMyTableDatas);
      yield put({
        type: 'show',
        payload: response,
      });
    },
  },

  reducers: {
    showTableData(state, { payload }) {
      return {
        ...state.data,
        payload,
        loading:false,
      };
    },
  },
};

